<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <script>
    // let arr = [3, 6, 9, 12, 15]
    // let narr = []
    // for (let i = 0; i < arr.length; i++) {
    //   narr.push(arr[i] + 10);
    // }

    // console.log(narr);
    // for (let i = 0; i <= 5; i++) {
    //   for (let j = 0; j <= i; j++) {
    //     document.write('*')
    //   }
    //   document.write('<br>')
    // }
    // let arr = [5, 8, 13, 6, 9, 12, 4]
    // let oddarr = []
    // let evenarr = []
    // for (let i = 0; i < arr.length; i++) {
    //   if (arr[i] % 2 === 0) {
    //     oddarr.push(arr[i])
    //   } else {
    //     evenarr.push(arr[i])
    //   }
    // }
    // let sum = 0
    // let ave = 0
    // let summ = 0
    // console.log(oddarr);
    // console.log(evenarr);
    // for (let i = 0; i < oddarr.length; i++) {
    //   sum += oddarr[i]
    // }
    // for (let i = 0; i < oddarr.length; i++) {
    //   summ += evenarr[i]

    // }
    // console.log(sum);
    // console.log(summ / evenarr.length);

    // let arr = 'Hello, how are you? I am fine, thank you!'
    // let narr = ''
    // let youcount = 0
    // for (let i = 0; i < arr.length; i++) {
    //   if (arr[i] === 'o') {
    //     narr += '*'
    //   } else {
    //     narr += arr[i]
    //   }
    //   if (arr[i] === 'y' & arr[i + 1] === 'o' && arr[i + 2] === 'u') {
    //     youcount++
    //   }
    // }
    // console.log(narr);
    // console.log(youcount);

    // let resultarr = [];
    // let sum = 1;
    // for (let i = 1; i <= 100; i++) {
    //   if (i % 3 === 0 && i % 5 !== 0) {
    //     resultarr.push(i);
    //   }
    // }
    // for (let i = 0; i < resultarr.length; i++) {
    //   sum *= resultarr[i];
    // }
    // console.log(resultarr);
    // console.log(sum);

    const students = [
      { name: '小明', score: 85, age: 13 },
      { name: '小红', score: 92, age: 14 },
      { name: '小刚', score: 78, age: 13 },
      { name: '小丽', score: 90, age: 14 }
    ];
    let age14Arr = []
    for (let i = 0; i < students.length; i++) {
      if (students[i].age === 14) {
        age14Arr.push(students[i])
      }
    }
    for (let i = 0; i < age14Arr - 1; i++) {
      for (let j = 0; j < age14Arr.length - 1 - i; j++) {
        if (age14Arr[j].score < age14Arr[j + 1].score) {
          let temp = age14Arr[j]
          age14Arr[j] = age14Arr[j + 1]
          age14Arr[j + 1] = temp
        }
      }
    }
    console.log("年龄为14岁的学生（按分数从高到低排序）：");
    for (let i = 0; i < age14Arr.length; i++) {
      console.log(`${age14Arr[i].name} - 分数：${age14Arr[i].score}`);
    }
    console.log(age14Arr);

  </script>
</body>

</html>